package com.alibaba.citrus.cr.common.enums.ordercenter;

import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

@Getter
public enum AsyncMessageEventEnum {
    FORECAST_ORDER_CREATE("预报订单创建", "ForecastOrder#create"),
    FORECAST_ORDER_CONFIRM("预报订单确认", "ForecastOrder#confirm"),
    SALES_ORDER_CREATE("销售订单创建", "SalesOrder#create"),
    SALES_ORDER_REFUSED("销售订单拒绝", "SalesOrder#refused"),
    SALES_ORDER_UPDATE("销售订单更新", "SalesOrder#update"),
    SALES_ORDER_DELETE("销售订单更新", "SalesOrder#delete"),
    RETURN_ORDER_CREATE("退货订单创建", "ReturnOrder#create"),
    RETURN_ORDER_REFUSED("退货订单拒绝", "ReturnOrder#refused"),
    RETURN_ORDER_UPDATE("退货订单更新", "ReturnOrder#update"),
    RETURN_ORDER_DELETE("退货订单更新", "ReturnOrder#delete"),
    EXCHANGE_ORDER_CREATE("换货订单创建", "ExchangeOrder#create"),
    EXCHANGE_ORDER_REFUSED("换货订单拒绝", "ExchangeOrder#refused"),
    EXCHANGE_ORDER_UPDATE("换货订单更新", "ExchangeOrder#update"),
    EXCHANGE_ORDER_DELETE("换货订单更新", "ExchangeOrder#delete"),
    ORDER_COMPLETED("订单完结", "ORDER_COMPLETED"),
    // other
    ;

    private final String label;
    private final String value;

    AsyncMessageEventEnum(String label, String value) {
        this.label = label;
        this.value = value;
    }

    public static AsyncMessageEventEnum of(String value) {
        return Arrays.stream(AsyncMessageEventEnum.values()).filter(source -> Objects.equals(value, source.getLabel())).findFirst().orElse(null);
    }

}
